package com.lottery.shadowbd.ui.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import com.lottery.shadowbd.R;
import com.lottery.shadowbd.ui.activity.LotRuleActivity;
import com.lottery.shadowbd.utils.ToastUtil;
import com.lottery.shadowbd.widget.SwitchButton;

import cn.jpush.android.api.JPushInterface;

/**
 * A simple {@link Fragment} subclass.
 */
public class LotSettingFragment extends BaseFragment implements CompoundButton.OnCheckedChangeListener {

    private View mView;

    private LinearLayout ll_lot_rule;
    private LinearLayout ll_set_update;
    private SwitchButton sw_notice;

    @Override
    protected View initView(LayoutInflater inflater) {
        mView = inflater.inflate(R.layout.fragment_lot_setting, null);

        ll_lot_rule = (LinearLayout) mView.findViewById(R.id.ll_lot_rule);
        ll_set_update = (LinearLayout) mView.findViewById(R.id.ll_set_update);

        sw_notice = (SwitchButton) mView.findViewById(R.id.sw_notice);

        return mView;
    }

    @Override
    protected void initData() {
        mContext = getActivity();
    }

    @Override
    protected void listener() {
        ll_set_update.setOnClickListener(this);
        ll_lot_rule.setOnClickListener(this);
        sw_notice.setOnCheckedChangeListener(this);
    }

    @Override
    protected void widgetClick(View v) {
        switch (v.getId()) {
            case R.id.ll_lot_rule://规则
                startActivity(new Intent(mContext, LotRuleActivity.class));
                break;
            case R.id.ll_set_update://检查更新
                ToastUtil.showShort(mContext, "已是最新版本");
                break;
            default:
                break;
        }
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            ToastUtil.showShort(mContext, "关闭消息推送");
        } else {
            ToastUtil.showShort(mContext, "打开消息推送");
        }
    }
}
